Type CalCoreAnimatedMorph

	Field m_duration:Float
	Field m_listCoreTrack:CalCoreMorphTrack[]
	Field m_tracksToDelete:CalCoreMorphTrack[]
	
	Method New()
		m_listCoreTrack=m_listCoreTrack[..0]
		m_tracksToDelete=m_tracksToDelete[..0]
	End Method
	
	
	Method addCoreTrack:Byte(pCoreTrack:CalCoreMorphTrack)
		m_listCoreTrack=m_listCoreTrack[..m_listCoreTrack.length+1]
		m_listCoreTrack[m_listCoreTrack.length-1] = pCoreTrack


		m_tracksToDelete=m_tracksToDelete[..m_tracksToDelete.length+1]
		m_tracksToDelete[m_tracksToDelete.length-1] = pCoreTrack
		
	
		Return True
	End Method
	
	Method removeZeroScaleTracks()
		'Local p:CalCoreMorphTrack[] = m_listCoreTrack[..]
		Local changed:Byte = True
		While changed
			changed = False
			'std::list<CalCoreMorphTrack>::iterator iteratorCoreTrack;
			For Local i:Int = 0 To m_listCoreTrack.length-1
				' get the core bone
				Local pCoreTrack:CalCoreMorphTrack
				pCoreTrack = m_listCoreTrack[i]
				Local morphNameList:CalCoreMorphKeyframe[] = pCoreTrack.getVectorCoreMorphKeyframes()
		
				Local nonZeroScaleTrack = False
				For Local keyframeId:Int = 0 To morphNameList.length-1
					Local weight:Float = morphNameList[keyframeId].getWeight()
					If weight <> 0.0 Then
						nonZeroScaleTrack = True
						Exit
					EndIf
				Next
				If nonZeroScaleTrack = False Then
					Local p:CalCoreMorphTrack[] = New CalCoreMorphTrack[m_listCoreTrack.length-1]
					Local idx:Int = 0
					For Local ii:Int = 0 To m_listCoreTrack.length-1
						If ii <> i Then
							p[idx] = m_listCoreTrack[ii]
							idx = idx + 1
						EndIf
					Next
					m_listCoreTrack = p
					changed = True
					Exit
				EndIf
			Next
		Wend		
	End Method

	Method getCoreTrack:CalCoreMorphTrack(name:String)
		For Local i:Int = 0 To m_listCoreTrack.length-1
			If m_listCoreTrack[i].getMorphName() = name Then Return m_listCoreTrack[i]
		Next
		Return Null
	End Method
	
	Method getDuration:Float()
		Return m_duration
	End Method
	
	Method getListCoreTrack:CalCoreMorphTrack[]()
		Return m_listCoreTrack
	End Method
	
	
	Method setDuration(duration:Float)
		m_duration = duration
	End Method	
	
	Method scale(factor:Float)
		For Local i:Int = 0 To m_listCoreTrack.length-1
			m_listCoreTrack[i].scale(factor)
		Next	
	End Method
End Type
